package com.molin.setTest;

import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;

public class Demo {
    public static void main(String[] args) {
        //set
        Set<String> set = new TreeSet<>();
        set.add("ab");
        set.add("abd");
        set.add("ab");
        set.add("abd");
        System.out.println(set);


        Iterator iterator=set.iterator();
        while (iterator.hasNext()){
            System.out.println(iterator.next());
        }
        System.out.println("-------------");
        for (String s : set) {
            System.out.println(s);
        }
    }
}
